using ASP;
using HoWave.Common;
using HoWave.Web;
using HoWave.Web.Admin;
using System;
using System.Data;
using System.Web.Profile;
using System.Web.SessionState;
using System.Web.UI.WebControls;
public class HL_Admin_Admin_ShopBank : Admin, IRequiresSessionState
{
	protected TextBox TextBox1;
	protected DropDownList UserDropDownList;
	protected GridView GridView1;
	protected Label PagePanel;
	private Shop_Bank _Bank = null;
	private int buyerid = 0;
	private string wherestr = "";
	private string orderbystr = "";
	private string linkhead = "";
	private bool m_tag = true;
	protected DefaultProfile Profile
	{
		get
		{
			return (DefaultProfile)this.Context.Profile;
		}
	}
	protected global_asax ApplicationInstance
	{
		get
		{
			return (global_asax)this.Context.ApplicationInstance;
		}
	}
	protected Shop_Bank m_Bank
	{
		get
		{
			Shop_Bank bank;
			if (this._Bank == null)
			{
				this._Bank = new Shop_Bank(this.conn);
				bank = this._Bank;
			}
			else
			{
				bank = this._Bank;
			}
			return bank;
		}
	}
	protected void Page_Load(object sender, EventArgs e)
	{
		if (!base.admin.CheckAdminPower(29))
		{
			base.WriteRightErrMsg();
		}
		this.BindUserDownList();
		if (!base.IsPostBack)
		{
			this.BindList();
		}
	}
	protected void BindUserDownList()
	{
		if (this.TextBox1.Text != "")
		{
			UserBll userBll = new UserBll();
			DataTable userNameIDByUserName = userBll.GetUserNameIDByUserName(this.TextBox1.Text.Trim());
			if (userNameIDByUserName.Rows.Count > 0)
			{
				string text = userNameIDByUserName.Rows[0]["UserName"].ToString();
				string text2 = userNameIDByUserName.Rows[0]["UserID"].ToString();
				foreach (ListItem listItem in this.UserDropDownList.Items)
				{
					if (listItem.Value.ToString() == text2.ToString())
					{
						this.TextBox1.Text = "";
						return;
					}
				}
				this.UserDropDownList.Items.Add(new ListItem(text, text2));
				this.UserDropDownList.SelectedValue = text2;
				this.TextBox1.Text = "";
			}
		}
	}
	protected void BindList()
	{
		int num = Fetch.GetID("page");
		if (num <= 0)
		{
			num = 1;
		}
		this.QuestString();
		int maxperpage = 15;
		if (this.GridView1.PageSize != 0)
		{
			maxperpage = Convert.ToInt32(this.GridView1.PageSize);
		}
		this.GridView1.DataSource = this.m_Bank.GetAllBank(num, maxperpage, this.wherestr, this.orderbystr);
		this.GridView1.DataBind();
		this.PagePanel.Text = this.m_Bank.GetPagePanel(this.linkhead);
	}
	protected void QuestString()
	{
		this.buyerid = Fetch.GetID("uid");
		if (this.buyerid != 0 && this.m_tag)
		{
			this.UserDropDownList.SelectedValue = this.buyerid.ToString();
		}
		else
		{
			this.buyerid = Convert.ToInt32(this.UserDropDownList.SelectedValue);
		}
		if (this.buyerid != -1)
		{
			this.wherestr = this.wherestr + "and UserID=" + this.buyerid;
			this.linkhead = this.linkhead + "&uid=" + this.buyerid;
		}
		if (this.wherestr != "")
		{
			this.wherestr = "and" + this.wherestr;
			this.wherestr = this.wherestr.Replace("andand", "where");
		}
	}
	protected void UserDropDownList_OnChange(object sender, EventArgs e)
	{
		this.m_tag = false;
		this.BindList();
	}
	protected void GridView1_DataBound(object sender, EventArgs e)
	{
		foreach (GridViewRow gridViewRow in this.GridView1.Rows)
		{
			if (!base.admin.CheckAdminPower(29))
			{
				gridViewRow.Cells[8].Enabled = false;
			}
		}
	}
	protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
	{
		bool flag = base.admin.CheckAdminPower(29);
		if (e.Row.RowType == DataControlRowType.DataRow)
		{
			e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#E7EDFE'");
			e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c;");
			if (!flag)
			{
				((LinkButton)e.Row.Cells[8].FindControl("cl")).Enabled = false;
			}
		}
	}
}
